<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <script type="text/javascript" src="./script/rem.js"></script>
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="yes" name="apple-touch-fullscreen">
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="./css/font-awesome.css" />
    <link rel="stylesheet" type="text/css" href="./css/style.css" />
    <script type="text/javascript" src="./script/jquery.min.js"></script>
    <script type="text/javascript" src="./script/aui-slide.js"></script>
    <script type="text/javascript" src="./script/jquery.min.js"></script>
    <script type="text/javascript" src="./script/doT.min.js"></script>
    <script type="text/javascript" src="./script/base.js"></script>
    <script type="text/javascript" src="./script/api.js"></script></head>
    <script type="text/javascript" src="./script/aui-tab.js" ></script>
    <script type="text/javascript" src="./script/jquery-3.2.0.js"></script>
    <script type="text/javascript" src="./script/aui-sharebox.js" ></script>
</head>
<body>

    <header class="head" style="padding-top:0.4rem;">
        <div class="head-l" tapmode onclick="closeWin()"><i class="fa fa-angle-left"></i></div>
        <h3>升级支付</h3>
        <div class="head-r"></div>
    </header>
    <div class="head-d" style="padding-top:0.4rem;"></div>

    <ul class="list-input-img mt20">
        <li>
            <img src="image/user-invite-icon-1.png">
            <label>支付密码：</label>
            <input type="password" id="password" placeholder="请输入密码">
        </li>
    </ul>

    <div class="btn-2 mt60" tapmode onclick="user_invite_success()">确定</div>


</body>
<script type="text/javascript" src="./script/api.js"></script>
<script type="text/javascript" src="./script/index.js"></script>
<script type="text/javascript">

    apiready = function(){
        userid = api.pageParam.id;
    }
    
    function user_invite_success() {

        // api.openWin({
        //     name: 'user_invite_success',
        //     url: './user_invite_success.html',
        // });

        // return false;

        $('#password').blur();
        var password = $api.byId('password').value;
        
        if (!password) {
            api.toast({
                msg: '请输入密码!',
                duration: 2000,
                location: 'bottom'
            });
            return false;
        }

        var token = $api.getStorage('token');
        api.ajax({
            url: webAddress + '/api/user/list/invite/upgrade',
            method: 'post',
            data: {
                values: { 
                   user_id: userid,
                   password: password,
               },
           },
           headers: {
            Authorization: 'Bearer ' + token,
            Accept: 'application/json',
        },
    },function(ret, err){
        if (ret) {
            // alert( JSON.stringify( ret ) );

            api.openWin({
                name: 'user_invite_success',
                url: './user_invite_success.html',
                pageParam:{
                    title: '升级成功!',
                }
            });
            
        } else {
            // alert( JSON.stringify( err ) );
            if (err.statusCode == 400) {
                api.toast({
                    msg: err.body.message,
                    duration: 2000,
                    location: 'bottom'
                });
                return false;
            }
        }
    });

    }
    function closeWin(){
        api.closeWin({
        });
    }
</script>
</html>